/*
 * @copyright: Huang Ding
 * @Author: ding-cx
 * @Date: 2021-02-26 17:15:12
 * @LastEditors: ding-cx
 * @LastEditTime: 2021-03-11 14:24:59
 * @Description: file content
 */

import { DataTypes } from "sequelize";
import * as moment from "moment";

export const modelCommonField = {
  create_user_id: {
    field: "create_user_id",
    comment: "创建者id",
    type: DataTypes.INTEGER,
  },
  edit_user_id: {
    field: "edit_user_id",
    comment: "修改者id",
    type: DataTypes.INTEGER,
  },
  createdAt: {
    type: DataTypes.DATE,
    get() {
      // console.log(1);
      return moment((this as any).getDataValue("createdAt")).format(
        "YYYY-MM-DD HH:mm:ss"
      );
    },
  },
  updatedAt: {
    type: DataTypes.DATE,
    get() {
      return moment((this as any).getDataValue("updatedAt")).format(
        "YYYY-MM-DD HH:mm:ss"
      );
    },
  },
};
